//----------------------------------------------------------------------------
//  ,-.
// /_\___ ,   Ninja Framework
// '  ___\    (C) Riccardo Capra - http://riccar.do
//  //   \\
//----------------------------------------------------------------------------
//  This program is free software: you can redistribute it and/or modify
//  it under the terms of the GNU General Public License as published by
//  the Free Software Foundation, either version 3 of the License, or
//  (at your option) any later version.
//
//  This program is distributed in the hope that it will be useful,
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//  GNU General Public License for more details.
//
//  You should have received a copy of the GNU General Public License
//  along with this program.  If not, see <http://www.gnu.org/licenses/>.
//----------------------------------------------------------------------------

#ifndef NJ_PLACEMENT_NEW_INLINE_H
#	define NJ_PLACEMENT_NEW_INLINE_H

	//----------------------------------------------------------------------------
	inline NjPlacementNew::NjPlacementNew()
#	if NJ_ASSERT_ENABLED
	:
		m_pAddress(NJ_NULL)
#	endif // NJ_ASSERT_ENABLED
	{
	}
	//----------------------------------------------------------------------------
	inline NjPlacementNew::NjPlacementNew(void * pAddress)
	:
		m_pAddress(pAddress)
	{
		NJ_ASSERT(pAddress!=NJ_NULL);
	}
	//----------------------------------------------------------------------------
	inline NjPlacementNew::NjPlacementNew(NjPlacementNew const & kAddress)
	:
		m_pAddress(kAddress.m_pAddress)
	{
		NJ_ASSERT(kAddress.m_pAddress!=NJ_NULL);
	}
	//----------------------------------------------------------------------------
	inline NjPlacementNew & NjPlacementNew::operator=(NjPlacementNew const & kAddress)
	{
		NJ_ASSERT(kAddress.m_pAddress!=NJ_NULL);
		m_pAddress=kAddress.m_pAddress;

		return (*this);
	}
	//----------------------------------------------------------------------------
	inline void * NjPlacementNew::GetAddress() const
	{
		NJ_ASSERT(m_pAddress!=NJ_NULL);
		return m_pAddress;
	}
	//----------------------------------------------------------------------------
	inline void NjPlacementNew::SetAddress(void * pAddress)
	{
		NJ_ASSERT(pAddress!=NJ_NULL);
		m_pAddress=pAddress;
	}
	//----------------------------------------------------------------------------
	inline void * operator new(size_t uSize, NjPlacementNew const & kPlacement)
	{
		NJ_UNUSED_VAR(uSize);

		return kPlacement.GetAddress();
	}
	//----------------------------------------------------------------------------
	inline void * operator new[](size_t uSize, NjPlacementNew const & kPlacement)
	{
		NJ_UNUSED_VAR(uSize);

		return kPlacement.GetAddress();
	}
	//----------------------------------------------------------------------------

#endif // NJ_PLACEMENT_NEW_INLINE_H
